import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:qgchat/common/global/global.dart';

class Loading extends StatelessWidget {

  Loading(this.isShow,{this.text=''});

  bool isShow;
  String text;

  @override
  Widget build(BuildContext context) {
    return Offstage(
      offstage: !isShow,
      child: AnimatedOpacity(
        opacity: isShow ? 1 : 0,
        duration: Duration(milliseconds: 300),
        child: Stack(
          children: <Widget>[
            Container(
              color: Color(0x99000000),
            ),
            Center(
              child: Container(
                padding: EdgeInsets.all(px(30)),
                decoration: BoxDecoration(
                  color: Color(0x99000000),
                  borderRadius: BorderRadius.all(Radius.circular(px(20))),
                ),
                child: Row(
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    CircularProgressIndicator(strokeWidth: 2.0,),
                    Offstage(
                      offstage: text=='',
                      child: Container(
                        margin: EdgeInsets.only(left: px(30)),
                        child: Text(
                          text,
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: px(40),
                          ),
                        ),
                      ),
                    )
                  ],
                ),
              ),
            ),
          ],
        ),
      )
    );
  }
}
